class CommentOn extends React.Component {
    async putWeibo(id, type) {
        await request.put(`/weibo/${id}/${type}`)
        this.props.getWeibo(this.props.pageNo)
    }
    async deleteWeibo(id){
        await request.delete("/weibo/"+id);
        this.props.getWeibo(this.props.pageNo);
    }
    render() {
        return (
            <>
                <div className="commentOn">
                    <div className="noContent" style={{ display: this.props.contentList.length === 0 ? "block" : "none" }}>暂无留言</div>
                    <div className="messList">
                        {
                            this.props.contentList.map((item) => {
                                return (
                                    <div className="reply" key={item._id}>
                                        <p className="replyContent">{item.content}</p>
                                        <p className="operation">
                                            <span className="replyTime">{item.addTime}</span>
                                            <span className="handle">
                                                <a href="" onClick={(e) => {
                                                    e.preventDefault()
                                                    this.putWeibo(item._id,1)
                                                }} className="top">{item.topNum}</a>
                                                <a href="" onClick={(e) => {
                                                    e.preventDefault()
                                                    this.putWeibo(item._id,2)
                                                }} className="down_icon">{item.downNum}</a>
                                                <a href="" onClick={(e) => {
                                                    e.preventDefault()
                                                    this.deleteWeibo(item._id)
                                                }} className="cut">删除</a>
                                            </span>
                                        </p>
                                    </div>
                                )
                            })
                        }
                    </div>
                    <PageList 
                    getWeibo={this.props.getWeibo}
                    pageSum={this.props.pageSum}
                    pageNo={this.props.pageNo}
                    />
                </div>

            </>
        )
    }
}
